import uniqueId from '@form-create/utils/lib/unique';
import {localeProps, makeRequiredRule} from '../../utils';

const label = '时间选择器';
const name = 'timePicker';

export default {
  icon: 'icon-time',
  label,
  name,
  rule({t}) {
    return {
      type: name,
      field: uniqueId(),
      title: t('components.timePicker.name'),
      info: '',
      $required: false,
      props: {},
    };
  },
  props(_, {t}) {
    return localeProps(t, name + '.props', [
      makeRequiredRule(),
      {
        type: 'input',
        field: 'placeholder',
        title: '非范围选择时的占位内容'
      },
      {
        type: 'input',
        field: 'format',
        title: '展示日期的格式'
      },
      {
        type: 'switch',
        field: 'use12Hours',
        title: '是否12小时制',
        value: false
      },
      {
        type: 'switch',
        field: 'editable',
        title: '文本框可输入',
        value: true
      },
      {
        type: 'switch',
        field: 'allowClear',
        title: '是否显示清除按钮',
        value: true
      },
      {
        type: 'Struct',
        field: 'pickerOptions',
        title: '当前时间日期选择器特有的选项',
        props: {defaultValue: {}}
      },
      {
        type: 'switch',
        field: 'readonly',
        title: '是否为只读模式'
      },
      {
        type: 'switch',
        field: 'disabled',
        title: '禁用'
      }
    ]);
  }
};
